package com.mrx.tunnel.controller;

import com.mrx.tunnel.model.TunnelRequest;
import com.mrx.tunnel.service.HttpTunnelService;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mr.X
 * @since 2024/8/31 08:17
 */
@RestController
@RequestMapping("/")
public class HttpTunnelController {

    @Resource
    private HttpTunnelService httpTunnelService;

    private static final Logger logger = LoggerFactory.getLogger(HttpTunnelController.class);

    @PostMapping("/ntunnel_sqlite.php")
    public ResponseEntity<?> handleTunnel(TunnelRequest request) {
        logger.info("handleTunnel request: {}", request);
        return ResponseEntity.ok(httpTunnelService.handleTunnel(request));
    }

}
